<?php namespace app\admin\controller;

use houdunwang\request\Request;
use system\model\Config as ConfigModel;

class Config extends Common{
	//利用中间件实现局部可控制性
	public function __construct()
	{
		$this->auth();
	}

	//动作
    public function index(){
        //此处书写代码...
    }

    public function setting(ConfigModel $config)
	{
		if(IS_POST)
		{
			$config->setConfig(Request::post());
			return $this->setRedirect('refresh')->success('操作成功');
		}
		//获取数据库的数据
		$model = ConfigModel::find(1);
		//如果能找到数据，将其转为数组，分配到页面
		//如果找不到数据，默认给空数组
		$field = $model ? json_decode($model['system'],true):[];
		return view('',compact('field'));
	}

}
